// Membership.cs
// Facebook/Framework/Service
// Copyright (c) 2007, Nikhil Kothari. All Rights Reserved.
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Facebook.Service.Core;

namespace Facebook.Service {

    /// <summary>
    /// Represents a membership list.
    /// </summary>
    public abstract class Membership : FacebookEntity {

        /// <summary>
        /// Initializes a FacebookMembership object with its state.
        /// </summary>
        /// <param name="membershipState">The state containing membership information.</param>
        protected Membership(Hashtable membershipState)
            : base(membershipState) {
        }

        /// <summary>
        /// Transforms a raw user list in the membership state into a list of user IDs.
        /// </summary>
        /// <param name="userList">The raw user list.</param>
        /// <returns>The list of user IDs.</returns>
        protected ICollection<string> TransformUserList(ArrayList userList) {
            if (userList == null) {
                return new string[0];
            }

            List<string> ids = new List<string>(userList.Count);
            foreach (object o in userList) {
                ids.Add(FacebookResponse.CoerceString(o));
            }

            return ids;
        }
    }
}
